Skip to content

get configuration from shared credentials on demand #2933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

HuanMeng0
Copy link

consider this situation:

a terraform project which manages multiple locations resources.

set credential with profile name "myorg1" by TCCLI, and set different regions in terraform providers.

provider "tencentcloud" {
  alias = "nanjing"
  profile  = "myorg1"
  region   = "ap-nanjing"
}


provider "tencentcloud" {
  alias = "shanghai"
  profile  = "myorg1"
  region   = "ap-shanghai"
}

latest version code would be exited with error: "Please set your secret_id and secret_key." since region attribute was set.

the changes fix it.

@HuanMeng0
Copy link
Author

please review this PR, thanks!

@hellertang

@SevenEarth
Copy link
Collaborator

SevenEarth commented Nov 7, 2024

@HuanMeng0 Thank you for your suggestion. We will optimize it as soon as possible. Due to business issues, we are unable to fully adopt your code. We will update it as follows:

	if v, ok := d.GetOk("secret_id"); ok {
		secretId = v.(string)
	}

	if v, ok := d.GetOk("secret_key"); ok {
		secretKey = v.(string)
	}

	if v, ok := d.GetOk("security_token"); ok {
		securityToken = v.(string)
	}

	if v, ok := d.GetOk("region"); ok {
		region = v.(string)
	}

	if secretId == "" && secretKey == "" && securityToken == "" {
		secretId = getProviderConfig("secretId")
		secretKey = getProviderConfig("secretKey")
		securityToken = getProviderConfig("token")
		if region == "" {
			region = getProviderConfig("region")
		}
	}

Thank you again for your suggestion

@HuanMeng0
Copy link
Author

closed.

due to #2944

@HuanMeng0 HuanMeng0 closed this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants